import request from "@/axios/axios.ts";
import {useStore} from '@/pinia'
const store = useStore()

import {HandlePie, InOutHistogram, PartDetail} from "@/api/first/DataAnalysis/type.ts";
enum API1 {
    A = '/first/handle_amount',
    B = '/first/history_date_amount',
    C = '/first/price_trend'
}
enum API2 {
    A = '/second/handle_amount',
    B = '/second/history_date_amount',
    C = '/second/price_trend'
}
enum API3 {
    A = '/first_new/handle_amount',
    B = '/first_new/history_date_amount',
    C = '/first_new/price_trend'
}

// 出入库和库存表
export const reqHandlePie = (data: HandlePie): Promise<any> => {
    if(store.axios_path === '1')
        return request.post<any, any>(API1.A, data)
    else if(store.axios_path === '2')
        return request.post<any, any>(API2.A, data)
    else
        return request.post<any, any>(API3.A, data)
}
//
export const reqInOutHistogram = (data: InOutHistogram): Promise<any> => {
    if(store.axios_path === '1')
        return request.post<any, any>(API1.B, data)
    else if(store.axios_path === '2')
        return request.post<any, any>(API2.B, data)
    else
        return request.post<any, any>(API3.B, data)
}

export const reqPartDetail = (data: PartDetail): Promise<any> => {
    if(store.axios_path === '1')
        return request.post<any, any>(API1.C, data)
    else if(store.axios_path === '2')
        return request.post<any, any>(API2.C, data)
    else
        return request.post<any, any>(API3.C, data)
}

